package testGame;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import satirGame.Performance;

public class performanceTest {
	private Performance performance;

	@Before
	public void setUp() throws Exception {
		performance = new Performance();
	}

	/*@Test
	public void testPerformance() {
		
	}*/

	@Test
	public void testSetCurPlayerChoice() {
		int cno=0;
		int curPlayerChoice = 1;
		performance.setCurPlayerChoice(curPlayerChoice);
		cno=curPlayerChoice;
		assertEquals(curPlayerChoice, cno);
	}

	@Test
	public void testSetOtherPlayerChoice() {
		int otherPlayerChoice =1;
		int cno =0;
		performance.setOtherPlayerChoice(otherPlayerChoice);
		cno=otherPlayerChoice;
		assertEquals(otherPlayerChoice, cno);
	}
	
	//if total other player = 5

	@Test
	public void testScore2() {
		boolean result = false; 
		int otherPlayerChoice=0;
		int curPlayerChoice=1;
		int totalChoice=5;
		int countSameChoice=0;
		
		if (curPlayerChoice==otherPlayerChoice) {
			countSameChoice++;
		}
		countSameChoice = totalChoice;
		assertEquals(result, true);	
	}
	
	@Test
	public void testScore1() {
		boolean result = false; 
		int otherPlayerChoice=0;
		int curPlayerChoice=1;
		int totalChoice=5;
		int countSameChoice=0;
		
		if (curPlayerChoice==otherPlayerChoice) {
			countSameChoice++;
			if(countSameChoice>=(totalChoice/2)){
				assertEquals(result, true);	
			}
		}
	}
	
	@Test
	public void testScoreM1() {
		boolean result = false; 
		int otherPlayerChoice=0;
		int curPlayerChoice=1;
		int totalChoice=5;
		int countSameChoice=0;
		
		if (curPlayerChoice==otherPlayerChoice) {
			countSameChoice++;
		}
		countSameChoice = totalChoice-totalChoice;
		assertEquals(result, true);	
	}
	
	@Test
	public void testScore0() {
		boolean result = false; 
		int otherPlayerChoice=0;
		int curPlayerChoice=1;
		int countSameChoice=0;
		
		if (curPlayerChoice==otherPlayerChoice) {
			countSameChoice++;
			if(countSameChoice >= 1 && countSameChoice <= 2){
				assertEquals(result, true);
			}
		}	
	}
}

/*----------------Version detail----------------------------

Modified time: 17:21_12/03/2012

Editor: Lam Pui Man Kathleen

Content: 

Add function for test case
testScore2()
testScore1()

Check:
testSetCurPlayerChoice()
testSetOtherPlayerChoice()
-----------------------------------------------------------*/

/*----------------Version detail----------------------------

Modified time: 22:37_20/03/2012

Editor: Lam Pui Man Kathleen

Content: 

Add check function for test case
testScore2()
testScore1()
testScoreM1()
testScore0()
-----------------------------------------------------------*/